<template>
	<view class="content">
		<image src="../../static/images/home/banner.png" mode="widthFix" class="bg-img"></image>
		<CustomNav :custom="custom" title="家政服务" :isBack="true" backColor="#fff" :topBgColor="topBgColor" color="#fff">
		</CustomNav>
		<view class="info-block">
			<view class="info-item">
				<view class="title FangZhengHanZhenGuangBiaoJianTi">家政服务</view>
				<view class="menu">
					<view class="menu-list" v-for="item in menuList" :key="item.id"
						@click="navigate('/pages/housekeeping/list?title='+item.name+'&id='+item.id)">
						<image :src="item.url" class="menu-img"></image>
						<view class="menu-name">{{item.name}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getCustomNavData
	} from '@/util/util.js'
	import {
		getCategoryApi
	} from '@/api/housekeeping.js'
	export default {
		data() {
			return {
				custom: null,
				topBgColor: 'rgba(0,0,0,0)',
				menuList: [{
						id: 1,
						img: '/static/images/news/jdanzhuang.png',
						title: '家电维修',
					},
					{
						id: 2,
						img: '/static/images/news/jshuishou.png',
						title: '家电安装',
					},
					{
						id: 3,
						img: '/static/images/news/qingxi.png',
						title: '家电清洗'
					},
					{
						id: 4,
						img: '/static/images/news/baojie.png',
						title: '保洁服务'
					},
					{
						id: 5,
						img: '/static/images/news/fuwu.png',
						title: '清洗服务'
					},
					{
						id: 6,
						img: '/static/images/news/yanghu.png',
						title: '家居养护'
					},
					{
						id: 7,
						img: '/static/images/news/banyun.png',
						title: '垃圾搬运',
						url: '',
					},
					{
						id: 8,
						img: '/static/images/news/qita.png',
						title: '其他'
					}
				],
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			getList() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getCategoryApi({
					name: '家政服务分类'
				}).then(data => {
					uni.hideLoading()
					this.menuList = data
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		onPageScroll(e) {
			if (e.scrollTop >= 1) {
				this.topBgColor = '#BA1519'
			} else {
				this.topBgColor = 'rgba(0,0,0,0)';
			}
		},
		onLoad() {
			this.custom = getCustomNavData();
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #F7F6F9;
		min-height: 100vh;

		.bg-img {
			width: 100%;
		}

		.info-block {
			display: flex;
			flex-direction: column;
			background: #F7F6F9;
			margin-top: -80rpx;
			border-radius: 60rpx;
			position: relative;
			padding: 30rpx;

			.info-item {
				background-color: #fff;
				padding: 30rpx;
				border-radius: 20rpx;

				.title {
					color: #BA1519;
				}

				.menu {
					display: flex;
					align-items: center;
					flex-wrap: wrap;
					margin-top: 30rpx;

					.menu-list {
						display: flex;
						flex-direction: column;
						width: calc(100% / 4);
						margin-top: 30rpx;
						justify-content: center;
						align-items: center;

						.menu-img {
							width: 110rpx;
							height: 110rpx;
							border-radius: 50%;
							margin-bottom: 15rpx;
						}

						.menu-name {
							font-size: 28rpx;
						}
					}
				}
			}
		}
	}
</style>